package com.burgeon.backend.SHOPBACKEND.controller;
/**
 * 活动预约页面
 */

import com.burgeon.backend.SHOPBACKEND.entity.booking.Bactivitie;
import com.burgeon.backend.SHOPBACKEND.entity.booking.BookingStoreData;
import com.burgeon.backend.SHOPBACKEND.service.BackendBookingActivitiesService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;

@RequestMapping("shopbackent/booking")
@RestController
@CrossOrigin
public class BackendBookingActivitiesController extends BaseController {

    @Autowired
    private BackendBookingActivitiesService backendBookingActivitiesService;

    /**
     * 记录查找
     * @param field A会员名 B会员手机
     * @param value
     * @param start
     * @param account
     * @return
     */
    @RequestMapping("findBactiviteRecord")
    public ResponseResult<HashMap> findBactiviteRecord(String field, String value, Integer start, String account) {
        HashMap  data = backendBookingActivitiesService.findBactiviteRecord(field,value,start,account);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    //预约记录
    @RequestMapping("getBactiviteRecord")
    public ResponseResult<HashMap> getBookingListData(Integer start, String account) {
        HashMap  data = backendBookingActivitiesService.getBactiviteRecord(start,account);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    //活动列表
    @RequestMapping("getBookingListData")
    public ResponseResult<List<Bactivitie>> getBookingListData(String account) {
        List<Bactivitie> data = backendBookingActivitiesService.getBookingListData(account);
        return new ResponseResult<List<Bactivitie>>(SUCCESS,data);
    }


    @RequestMapping("storeData")
    public ResponseResult<List<BookingStoreData>> storeData(String account) {
        List<BookingStoreData> data = backendBookingActivitiesService.getStoreData(account);
        return new ResponseResult<List<BookingStoreData>>(SUCCESS,data);
    }

    @RequestMapping("addData")
    public ResponseResult<Void> addData(String name, String stateTime, String endTime,
                                        String[] stores, Integer count,
                                        String account, String explain,
                                        @RequestParam(value = "img") MultipartFile img) {
        backendBookingActivitiesService.addData(name,stateTime,endTime,stores,count,account,explain,img);

        return new ResponseResult<>(SUCCESS);
    }


}
